package io.renren.modules.jxgk.service.impl;

import io.renren.modules.jxgk.dao.ClassAttendenceInfoDao;
import io.renren.modules.jxgk.dao.StudentAttendenceInfoDao;
import io.renren.modules.jxgk.entity.ClassAttendenceEntity;
import io.renren.modules.jxgk.entity.ClassAttendenceInfoEntity;
import io.renren.modules.jxgk.entity.StudentAttendenceInfoEntity;
import io.renren.modules.jxgk.service.ClassAttendenceInfoService;
import io.renren.modules.jxgk.service.StudentAttendenceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ClassAttendenceInfoServiceImpl implements ClassAttendenceInfoService {
    @Autowired
    ClassAttendenceInfoDao classAttendenceInfoDao;
    @Override
    public List<ClassAttendenceInfoEntity> queryList(Map<String, Object> map){
        List<ClassAttendenceInfoEntity> list=classAttendenceInfoDao.queryList(map);
        for(ClassAttendenceInfoEntity s:list){
            s.setChuqin(s.getTotal()-s.getChidao()-s.getKuangke()-s.getQingjia()-s.getZaotui());
            switch (s.getCourseWhichDay())
            {
                case  "1":s.setCourseWhichDay("星期一");break;
                case  "2":s.setCourseWhichDay("星期二");break;
                case  "3":s.setCourseWhichDay("星期三");break;
                case  "4":s.setCourseWhichDay("星期四");break;
                case  "5":s.setCourseWhichDay("星期五");break;
                case  "6":s.setCourseWhichDay("星期六");break;
                case  "7":s.setCourseWhichDay("星期天");break;
            }
            int j=Integer.parseInt(s.getCourseWhichIndex())+1;
            s.setCourseWhichIndex("第"+s.getCourseWhichIndex()+"-"+j+"节");
            s.setCourseWhichWeek("第"+s.getCourseWhichWeek()+"周");
            if(s.getCourseAcademicTerm().equals("1"))
            {
                s.setCourseAcademicTerm("第一学期");
            }else
            {
                s.setCourseAcademicTerm("第二学期");
            }
        }
        return list;
    }
    public int queryTotal(Map<String, Object> map){
        return  classAttendenceInfoDao.queryTotal(map);
    }

    @Override
    public int queryDetailsTotal(Map<String, Object> map){
        return  classAttendenceInfoDao.queryDetailsTotal(map);
    }

    @Override
    public List<ClassAttendenceEntity> selectAttendenceDetails(Map<String, Object> map){
        return classAttendenceInfoDao.selectAttendenceDetails(map);
    }
}
